﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SeaBattle.Domain.Entities
{
    /// <summary>
    /// Class ShipParts
    /// </summary>
    public class ShipPart
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ShipPart"/> class.
        /// </summary>
        public ShipPart(Ship ship, int XCoord, int YCoord, bool alive = true)//TODO: Add comments.
        {
            this.Ship = ship;
            this.Alive = alive;
            this.XCoord = XCoord;
            this.YCoord = YCoord;
        }
        /// <summary>
        /// Gets or sets the ship.
        /// </summary>
        /// <value>
        /// The ship.
        /// </value>
        public Ship Ship { get; private set; }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="ShipPart"/> is alive.
        /// </summary>
        /// <value>
        ///   <c>true</c> if alive; otherwise, <c>false</c>.
        /// </value>
        public bool Alive { get; private set; }

        public int XCoord { get; private set; }

        public int YCoord { get; private set; }

        public void ReceiveShot(int X,int Y)
        {
            if (this.XCoord != X || this.YCoord != Y)
                throw new ApplicationException("Finded wrong target. The coords is not the same.");
            Alive = false;
        }
    }
}
